#include "defectdetectiondialog.h"
#include "ui_defectdetectiondialog.h"
#include "../mainwindow.h"

#include "../parameter/imageinfo.h"

SeatDetection* pSeatDetection = nullptr;

DefectDetectionDialog::DefectDetectionDialog(QWidget *parent)
    : QDialog(parent)
    , ui(new Ui::DefectDetectionDialog)
{
    ui->setupUi(this);

    m_pSeatDetection = MainWindow::instance()->GetSeatDetection();

    ImageInfo& camerainfo = m_pSeatDetection->GetImageInfo();

    qDebug() << camerainfo.GetImageChannel();
}

DefectDetectionDialog::~DefectDetectionDialog()
{
    delete ui;
}




void DefectDetectionDialog::on_pushButtonExit_clicked()
{
    this->close();
}


void DefectDetectionDialog::on_pushButtonIsolation_clicked()
{

}

void DefectDetectionDialog::on_pushButtonReset_clicked()
{
    // （1） 获得 参数
    pSeatDetection = MainWindow::instance()->GetSeatDetection();
    // （2） 初始化
    /*DescriptionInitThread* pDescriptionInitThread = new DescriptionInitThread(this);
    pDescriptionInitThread->SetDevices(pSeatDetection->GetDescription().GetDevices());
    pDescriptionInitThread->start();*/

    foreach (Device *pDevice, pSeatDetection->GetDescription().GetDevices()) {
        pDevice->initDevice();
    }
    qDebug() << "所有设备初始化完成！";
    // 设置所有设备初始状态标志，避免重复被初始化
    pSeatDetection->GetDescription().SetAllInitialized(true);
}

void DefectDetectionDialog::on_pushButtonRelease_clicked()
{
    // （3）运行
    pSeatDetection->GetDescription().run();
}

